<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://www.ufida.com/lfw" prefix="lfw" %>
<%@ taglib uri="http://www.ufida.com/uif" prefix="uif" %> 
<%@ taglib uri="http://www.ufida.com/lfwtool" prefix="lfwtool" %> 
<%@ taglib uri="http://www.ufida.com/multilang" prefix="ml" %> 
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@page import="nc.lfw.core.LfwRuntimeEnvironment"%>
<%@page import="nc.lfw.billtemplate.controller.ILfwBillControllerBase"%>
<%@page import="nc.lfw.billtemplate.controller.IManageControllerBase"%>
<html>
	<head>
		<lfw:base/>
		<lfw:head/>
		<uif:import type="0" supportPf="true"/>
		<script type='text/javascript' src='${ROOT_PATH}/html/nodes/jkbxscript/JkbxConstant.js'></script>
		<script type='text/javascript' src='${ROOT_PATH}/html/nodes/jkbxscript/JkbxCurrencyUtils.js'></script>
		<script type='text/javascript' src='${ROOT_PATH}/html/nodes/jkbxscript/JkbxButtonManager.js'></script>
		<script type='text/javascript' src='${ROOT_PATH}/html/nodes/jkbxscript/DefEditFormular.js'></script>
		<style>
			#bodyContainer{
				width:100%;
				height:100%; 
				padding-left:5px;
				padding-right:5px;
				padding-bottom:5px;
				overflow:hidden;
			}
		</style>
	</head>
	<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" scroll=no onload="pageBodyScript()">
		<%
			ILfwBillControllerBase ctrl = (ILfwBillControllerBase)LfwRuntimeEnvironment.getWebContext().getController();
			Integer cardIndex = new Integer(0);
			if(ctrl != null){
				cardIndex = ((IManageControllerBase)ctrl).showCardFirst()? new Integer(1) : new Integer(0);
			}
			pageContext.setAttribute("cardIndex", cardIndex);
		%>
		
		<lfw:pageModel className="${lfwtool:getInfo('modelClazz')}" showLoadingPage="false">
			<lfw:layout type="border">
				<lfw:layoutPanel position="top" height="26px">
					<lfw:menubar id="menubar2"/>
					<lfw:menubar id="menubar1"/>
				</lfw:layoutPanel>
				<lfw:layoutPanel position="center">
					<table width="100%" height="100%" cellpadding="0" cellspacing="0">
						<tr>
							<td>
								<div id="bodyContainer">
									<table style="width:100%;height:100%">
										<tr height="260" id="toptr">
											<td>
												<lfw:layout type="card" cardId="billCard" border="0" cardIndex="${cardIndex}">
													<lfw:layoutPanel cardId="card1">
														<lfw:border width="1">
															<lfw:grid id="headTab_jkzb_grid" />
														</lfw:border>
													</lfw:layoutPanel>
													<lfw:layoutPanel cardId="card2">
														<lfw:tab id="headTabCard">
															<lfw:components componentType="nc.lfw.core.comp.FieldsetComp" var="fieldsets"/>
																<c:forEach var="item" items="${headTabCard.itemList}">
																	<lfw:tabitem id="${item.id}">
																		<div style="overflow:auto;height:100%;">
																			<table width="100%" height="100%">
																				<tr valign="top">
																					<td>
																						<div id="outer_headTab_${item.id}_form" style="height:140px">
																							<lfw:form id="headTab_${item.id}_form" />
																						</div>
																					</td>
																				</tr>
																				<c:forEach var="fieldset" items="${fieldsets}">
																					<c:if test="${fieldset.userObj == item.id}">
																						<tr>
																							<td>
																								<lfw:fieldset id="${fieldset.id}">
																									<div id="outer_headTab_${fieldset.id}_form" style="height:30px">
																										<lfw:form id="headTab_${fieldset.id}_form" />
																									</div>
																								</lfw:fieldset>
																							</td>
																						</tr>
																					</c:if>
																				</c:forEach>
																			</table>
																		</div>
																	</lfw:tabitem>
																</c:forEach>
														</lfw:tab>
													</lfw:layoutPanel> 
												</lfw:layout>
											</td>
										</tr>
										<tr id="centertr">
											<td>
												<lfw:tab id="bodyTab">
													<lfw:tabspace id="rightSpace" width="220" position="right">
														<div style="height:95%;overflow:hidden;">
															<lfw:menubar id="menubar_body"/>
														</div>
													</lfw:tabspace>
													<c:forEach var="item" items="${bodyTab.itemList}">
														<lfw:tabitem id="${item.id}">
															<lfw:border width="1">
																<lfw:grid id="bodyTab_${item.id}_grid" />
															</lfw:border>
														</lfw:tabitem>
													</c:forEach>
												</lfw:tab>
											</td>
										</tr>
										<tr height="32" id="tailtr">
											<td>
												<lfw:form id="tailTab_tail_form"/>
											</td>
										</tr>
									</table>
								</div>
							</td>
						</tr>
					</table>	
				</lfw:layoutPanel>
			</lfw:layout>
		</lfw:pageModel>
		<script>
			<%@ include file="/html/nodes/jkbxscript/JkbxCommonLogic.jsp"%>
			<%@ include file="/html/nodes/jkbxscript/JkbxCommonUtils.jsp"%>
			<%@ include file="jkmanageuiutil.jsp"%>
			<%@ include file="/html/nodes/jkbxscript/JkbxCopyAction.jsp"%>
			<%@ include file="/html/nodes/jkbxscript/JkbxDeleteAction.jsp"%>
			<%@ include file="/html/nodes/jkbxscript/JkBxApproveAction.jsp"%>
			<%@ include file="/html/nodes/jkbxscript/JkBxUnapproveAction.jsp"%>
			
			<c:forEach var="item" items="${bodyTab.itemList}">
				<c:if test="${item.id ne 'er_bxcontrast'}">
					function bodyTab_${item.id}_gridFilter(row)
					{
						var bodyTab = getComponent("bodyTab");
						var item = bodyTab.getSelectedItem();
						var tabcode = '${item.id}';
						var ds = getDataset("jk_items");
						var colIndex = ds.nameToIndex('tablecode');
						return row.getCellValue(colIndex) == tabcode;
					}
				</c:if>
			</c:forEach>
						
			// 针对IE7不能正确显示margin-right的特殊处理,必须通过代码设置
			//$("bodyContainer").style.marginRight = "10px";
			function externalInit()
			{
				// 去掉menubar多余的边线
				var menubar1Comp = getComponent("menubar1");
				if(menubar1Comp != null)
				{
					menubar1Comp.Div_gen.style.borderRight = "none";
					menubar1Comp.Div_gen.style.borderLeft = "none";
					menubar1Comp.Div_gen.style.borderTop = "none";
				}
				
				var menubar2Comp = getComponent("menubar2");
				if(menubar2Comp != null)
				{
					menubar2Comp.Div_gen.style.borderRight = "none";
					menubar2Comp.Div_gen.style.borderLeft = "none";
					menubar2Comp.Div_gen.style.borderTop = "none";
				}
				
				var menubarBody = getComponent("menubar_body");
				if(menubarBody != null)
				{
					menubarBody.Div_gen.style.border = "none";
					menubarBody.Div_gen.style.background = "transparent";
				}
				if(typeof postInit != 'undefined')
					postInit();
			}

			function globalBeforeOpenRefDialog(refComp) {
				var ds = getDataset('jk_jkzb');
				var row = ds.getSelectedRow();
				var valueArr = "";
				var rowSize = row.getSize();

				//如果是参照的名称字段，则设置为空，为了url长度 < 2k
				var refIndexMap = new HashMap();
				var meta = ds.metadata;
				for(var t = 0, count = meta.length; t < count; t++){	
					if(meta[t].refField1 != null && meta[t].refField1 != '')
						refIndexMap.put(t,t);
					if(meta[t].key == 'zyx10')
						refIndexMap.put(t,t);
				}
				
				//用+=连接字符串效率低，根据需要修改此处
				for(var i = 0; i < rowSize; i ++){
					if(refIndexMap != null && refIndexMap.size != 0){
						if(refIndexMap.containsKey(i)){
							valueArr += '';
							if(i != rowSize - 1)
								valueArr += ",";
							continue;
						}
					}
					var value = row.getCellValue(i);
					if(value != null){
						valueArr += value;
					}
					if(i != rowSize - 1)
						valueArr += ",";
				}
				return "rowValueArr=" + encodeURIComponent(valueArr) + "&djlxbm=" + getSessionAttribute("djlxbm") + "&djdl=jk";
			}
			
			function onBeforeDestroyPage()
			{
				// 用户已经注销则不继续执行
				if(parent.$logoutflag != null && parent.$logoutflag == true)
					return false;
			}
			
			function specialCellLogicCheck(dataset, value, index, row) 
			{ 
				return true;
			}
			function globalFormInitialized(form) {
				var div = $('outer_' + form.id);
				if(div == null)
					return;
				var height = form.getHeight();
				div.style.height = height;
			}
		</script>
	</body>
</html>